<template>
  <!--    <NuxtWelcome />-->

  <VApp :theme="customizeTheme.darkTheme ? 'dark' : 'light'">
    <!--    ant design vue-->
    <a-config-provider
        :theme="{algorithm:customizeTheme.darkTheme?theme.darkAlgorithm:theme.defaultAlgorithm,
        token:{
          colorBgContainer:'transparent',
        }
        }"
    >
      <NuxtLayout>
        <NuxtLoadingIndicator color="primary"/>
        <NuxtPage></NuxtPage>
          <!-- 定义样式 -->
          <customization-menu/>
          <!-- 返回顶部 -->
          <back-to-top/>
          <snackbar/>
      </NuxtLayout>
    </a-config-provider>
  </VApp>
</template>
<script setup lang="ts">
import BackToTop from "~/components/common/BackToTop.vue";
import Snackbar from "~/components/common/Snackbar.vue";
import CustomizationMenu from "~/components/CustomizationMenu.vue";


const customizeTheme = useCustomizeThemeStore();
import {theme} from 'ant-design-vue';
import type {APPSetting} from "~/stores/appStore";

// Composition API
// import { usePrimeVue } from 'primevue/config';
// const PrimeVue = usePrimeVue();
//
// onMounted(()=>{
//   // handleChangeTheme()
// })
// const  handleChangeTheme = ()=>{
//   PrimeVue.changeTheme('aura-dark-blue', 'aura-light-blue', 'primevue/resources/themes/aura-light-blue/theme.css', () => {});
// }

//获取用户的浏览器模式
// const mode = useColorMode()
const colorMode = useColorMode()
customizeTheme.darkTheme = colorMode.value == 'dark'
// console.log('当前系统的颜色模式' + colorMode.value)


onBeforeMount(async () => {
  await getAppPageContent()
  useHead({
    title: {
      textContent: appPageContent.value.website_title
    },
    meta: [
      // <meta name="viewport" content="width=device-width, initial-scale=1">
      {name: 'google-site-verification', content: '4SOiCOVLrSZsGqZKhVt7dEKsatxjHCU5TfwcPkpvU1E'},
      {name: 'viewport', content: 'width=device-width, initial-scale=1,user-scalable=no'},
      {
        name: 'description',
        content: '一款跨平台的AI工具，只需要点点鼠标就可以完成各种自媒体和商业文案，商业大片、商品图片和模特写真，更有AI文生视频，助力自媒体创作'
      },
      {name: 'keywords', content: 'AI文案，AI工具，AI摄影，chatGPT,sora,AI视频，AI写真，AI电商'},
    ],
    link: [
      {
        id: 'theme-link',
        rel: 'stylesheet',
        href: '/themes/aura-dark-green/theme.css'
      }
    ]
  })
})
//获取页面配置
const {appPageContent,operationConfig,licence}=storeToRefs(useAppStore())
const getAppPageContent=async () => {
  const _res = await Client_GET('/content') as APPSetting
  if (_res){
    appPageContent.value=_res.page_content
    operationConfig.value.enableMultiTask=_res.operation_config.enableMultiTask
    licence.value=_res.licence||''
    // console.log('获取页面配置内容'+_res.page_content)
  }
}


//修改meta标签的内容
useSeoMeta({
  // title: '我的神奇网站',
  // ogTitle: '我的神奇网站',
  // description: '这是我的神奇网站，让我来告诉你关于它的一切。',
  // ogDescription: '这是我的神奇网站，让我来告诉你关于它的一切。',
  // ogImage: 'https://example.com/image.png',
  // twitterCard: 'summary_large_image',
})

</script>